#include "m_studentinsert.h"
#include "ui_m_studentinsert.h"

#include <QMessageBox>
#include <QSqlQuery>

M_studentInsert::M_studentInsert(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::M_studentInsert)
{
    ui->setupUi(this);
}

M_studentInsert::~M_studentInsert()
{
    delete ui;
}

void M_studentInsert::on_confirmBtn_accepted()
{
    QSqlQuery query;
    QString sid=ui->sidEdit->text();
    QString sname=ui->snameEdit->text();
    QString ssex=ui->ssexEdit->text();
    QString sphone=ui->sphoneEdit->text();
    QString scollege=ui->scollegeEdit->text();
    QString sdept=ui->sdeptEdit->text();
    QString sroomid=ui->sroomEdit->text();
    QString sbuildid=ui->sbuildEdit->text();
    QString spwd=ui->spwdEdit->text();

    QString str=QString("insert into student values('%1','%2','%3','%4','%5','%6','%7','%8','%9')").
            arg(sid).arg(sname).arg(ssex).arg(sphone).arg(scollege).arg(sdept).arg(sroomid).arg(sbuildid).arg(spwd);
    qDebug()<<str;
    if(query.exec(str)==true){
        QMessageBox::information(NULL,"tips","插入成功");
        this->close();
    }
    else QMessageBox::warning(NULL,"Error","插入失败，请检查是否有内容写错");

}


void M_studentInsert::on_confirmBtn_rejected()
{
   this->close();
}

